package com.lwj.liwanjia.view.activity.myindent.tuikuantuihuo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.base.BaseActivity;
import com.lwj.liwanjia.bean.IndentDetailBean;

import java.io.Serializable;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TuiKuanActivity extends BaseActivity {

    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_shangpin)
    ImageView ivShangpin;
    @BindView(R.id.tv_shangpin)
    TextView tvShangpin;
    @BindView(R.id.tv_jianjie)
    TextView tvJianjie;
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.tv_num)
    TextView tvNum;

    private String tradeId;
    private IndentDetailBean.DataBean.CommodityBean commodity;

    @Override
    protected void initView() {
        tvLeft.setVisibility(View.VISIBLE);
        tvTitle.setText("售后");
        Intent intent = getIntent();
        tradeId = intent.getStringExtra("tradeId");
        commodity = (IndentDetailBean.DataBean.CommodityBean) intent.getSerializableExtra("goods");
        if (tradeId != null) {
            Glide.with(this).load(commodity.getCommodityimage()).error(R.mipmap.tupian).into(ivShangpin);
            tvShangpin.setText(commodity.getCommodityname());
            tvJianjie.setText(commodity.getCommodityinfo());
            tvPrice.setText("￥" + commodity.getCommodityprice());
            tvNum.setText("*" + commodity.getCommodityNum());
        }
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_tui_kuan;
    }

    @OnClick({R.id.tv_left, R.id.rl_tuikuan, R.id.rl_huanhuo, R.id.rl_huokuan})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_left:
                finish();
                break;
            case R.id.rl_tuikuan://仅退款
                Intent intent = new Intent(TuiKuanActivity.this, TuiKuanDetailActivity.class);
                intent.putExtra("type", "仅退款");
                intent.putExtra("tradeId", tradeId);
                intent.putExtra("goods", commodity);
                startActivity(intent);
                break;
            case R.id.rl_huanhuo://仅换货
                Intent intent1 = new Intent(this, HuanhuoDetailActivity.class);
                intent1.putExtra("tradeId", tradeId);
                intent1.putExtra("goods", commodity);
                startActivity(intent1);
                break;
            case R.id.rl_huokuan://退货退款
                Intent intent3 = new Intent(TuiKuanActivity.this, TuiKuanDetailActivity.class);
                intent3.putExtra("type", "退货退款");
                intent3.putExtra("tradeId", tradeId);
                intent3.putExtra("goods", commodity);
                startActivity(intent3);
                break;
        }
    }
}
